from flask.views import View
from flask import  request,Flask

app=Flask(__name__)
class IndexView(View):
    methods = ['GET']

    def dispatch_request(self):
        if request.method == 'GET':
            data = {'name': '张三', 'age': 30}
            return data

app.add_url_rule('/', view_func=IndexView.as_view('index'))

if __name__ == '__main__':
    app.run()


